-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the relative phase Toffoli gates #3761
Conversation
…_phase_toffoli_gates
We can just call it the Margolus gate? See #1741 (item 8) and https://arxiv.org/abs/quant-ph/0312225. For now I think drawing it with a box and its name inside makes sense, unless we can come up with a modified notation for ccx that shows a relative phase difference. This is not a
|
Agreed to not having it as controlled gate, that solves the issue. 👍 However I'm not sure about Margolus gate, since (1) we tried to get consistent "action-based" gate names, and (2) how would we call the method then? |
Ok I'm fine leaving rccx (that causes least disruption for now). I would at least put Margolus / Simplified Toffoli in the documentation because that seems a more common way of referring to this gate. There's some limit to "action-based" descriptions of gates, as gates have come to have common names in the literature and community. Like S gate and V gate, whose actions are basically rz90 and sqrt-x, but everyone just refers to them by the former names. |
…_phase_toffoli_gates
Ok, I left the method name as |
…kit-terra into relative_phase_toffoli_gates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good mostly, some minor comments
Co-Authored-By: Ali Javadi-Abhari <[email protected]>
Co-Authored-By: Ali Javadi-Abhari <[email protected]>
* implement relative phase toffoli gates as gates * fix CX, Cnot mixup * update init, remove unused import * add matrix repr, fix num_qubits * add test on relative phase toffolis * remove base_gate, X does not really apply * make Gate, not ControlledGate, update docstrings * rename to RCCX * add qasm definitions * update str length due to rcc(c)x definitions * fix deprecation warning and test * rename tgt/ctl to full names * Correct docstring Co-Authored-By: Ali Javadi-Abhari <[email protected]> * Correct docstring Co-Authored-By: Ali Javadi-Abhari <[email protected]> Co-authored-by: Ali Javadi-Abhari <[email protected]>
Summary
Implement the relative phase Toffoli gates (CCX and CCCX), which only existed as functions and not
Gate
s. These gates are used in the definition of other multi-controlled gates and are blocking their implementation.Details and comments
These gates follow https://arxiv.org/pdf/1508.03273.pdf. The relative-phase CCX is shown in Fig. 3, dashed box and the relative-phase CCCX is shown in Fig. 4, the whole circuit.
Things left to decide:
rccx
, which conflicts with the naming scheme we introduce in Consistent naming of controlled gates #3633 where we useR
to denote a rotation.Edit: Named
rccx/RCCXGate
since the method is already calledrccx
.X
as base gate suggests that they are the same as the Toffolis -- which they are not.Edit: Resolved by not being a controlled gate, thus the name is drawn in a box (composite gate style).
base_gate
? The first idea might be to use theXGate
as base gate, but this is not accurate, as the base gate implies that the controlled gate can be written ascontrolled_gate = |0><0| \times id + |1><1| \times X
.Also this runs into problems with the default mechanisms of Qiskit to create a controlled gate.
If they don't have a
base_gate
this must be accordingly dealt with in the circuit drawer.Edit: Resolved by not being a
ControlledGate
butGate
type for now.